package com.commons.web.config;



import org.springframework.context.annotation.*;
import springfox.documentation.builders.*;
import springfox.documentation.oas.annotations.*;
import springfox.documentation.service.*;


import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.*;

@Configuration
@EnableOpenApi
public class Swagger3Config {
    Boolean swaggerEnabled = true;

    @Bean
    public Docket createRestApi() {
        return new Docket(DocumentationType.OAS_30)
                .apiInfo(apiInfo())
                // 是否开启
                .enable(swaggerEnabled)
                .select()
                // 指定接口的位置
                .apis(RequestHandlerSelectors.basePackage("com.commons.web.controller"))
                .paths(PathSelectors.any())
                .build();
    }

    /**
     * 配置网站的基本信息
     *
     * @return
     */
    private ApiInfo apiInfo() {
        return new ApiInfoBuilder()
                // 网站标题
                .title("服务接口文档")
                // 联系人信息
                .contact(new Contact("w", "http://localhost:8085/swagger-ui/index.html#/", "xxx@qq.com"))
                // 版本号
                .version("1.0")
                // 描述
                .description("集成Netty服务")
                .build();
    }

}
